$(function() {
	var phoneNum=Common.queryGetParam("phoneNum");
    $("#phoneNum").val(phoneNum);
});


/**
 * 领取彩票
 */
function qrSend() {
	var denomination=Common.queryGetParam("denomination");
	var paramStr = {};
	paramStr.phoneNum = $("#phoneNum").val();
	paramStr.merchantId = "e3ead303d51b4b41a8653209800dadb4";
	if(null == denomination || "undefined" == typeof(denomination) || "" == denomination){
		paramStr.denomination=2;
	}else{
		paramStr.denomination=denomination;
	}
	var params = {};
	params.paramStr = JSON.stringify(paramStr);
	var url1 = "";
	var url2 = "";
	Common.ajaxWithParam("/fenful/api/v1/common/getLotteryUnionId", params, function(res) {
		console.log(res);
		url1 = res.baseUrl + "?uniqueid=" + res.uniqueid;
		$.ajax({
			type: "get",
			url: url1,
			dataType: 'jsonp',
			success: function(res) {
				console.log(res);
				if(res.resultCode!='200'){
					layer.msg('请确认领取');
					return;
				}
				Common.ajaxWithParam("/fenful/api/v1/common/lotteryQrcodeSend", params, function(res) {
                    var qrCode=res.qrCode;
                    if(null == qrCode || "undefined" == typeof(qrCode) || "" == qrCode) {
                        url2 = res.wzlQrcodeUrl;
                    }else {
                        url2 = res.wzlQrcodeUrl + "?qrCode=" + qrCode + "&qrType=1";
					}
                    window.location.href=url2;
				});
			},
			error: function() {
				layer.msg('请求失败');
			}

		});

	});
}
/**
 * 联合登录
 */
function unionLogin() {
	var denomination=Common.queryGetParam("denomination");
	var paramStr = {};
	paramStr.phoneNum = $("#phoneNum").val();
	paramStr.merchantId = "e3ead303d51b4b41a8653209800dadb4";
	if(null == denomination || "undefined" == typeof(denomination) || "" == denomination){
		paramStr.denomination=2;
	}else{
		paramStr.denomination=denomination;
	}
	var params = {};
	params.paramStr = JSON.stringify(paramStr);
	var url1 = "";
	var url2 = "";
	Common.ajaxWithParam("/fenful/api/v1/common/getLotteryUnionId", params, function(res) {
		console.log(res);
		url1 = res.baseUrl + "?uniqueid=" + res.uniqueid;
		$.ajax({
			type: "get",
			url: url1,
			dataType: 'jsonp',
			success: function(res) {
				console.log(res);
				if(res.resultCode!='200'){
					layer.msg('服务器繁忙，请重试！');
					return;
				}
				window.location.href="http://www.jfcaipiao.com/index.html";
			},
			error: function() {
				layer.msg('请求失败');
			}

		});

	});
}



